﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using VOL.Core.DBManager;
using VOL.Core.Extensions;
using VOL.Entity.DomainModels;

namespace VOL.WebApi.Controllers.MyTable.Partial
{
    [Route("api/fwb_receive_info")]
    [ApiController]
    public class fwb_receive_info:Controller
    {
        [HttpPost,Route("updateData"),AllowAnonymous]
        public Boolean UpdateData([FromBody] SaveModel saveModel) 
        {
            try
            {
                string fwb_prize_draw_info_id = saveModel.MainData.GetValue("fwb_prize_draw_info_id").ToString();
                string winner_name = saveModel.MainData.GetValue("winner_name").ToString();
                string winner_phone_number = saveModel.MainData.GetValue("winner_phone_number").ToString();
                string winner_delivery_address = saveModel.MainData.GetValue("winner_delivery_address").ToString();
                string sql = "update fwb_prize_draw_info set winner_name = @winner_name, winner_phone_number = @winner_phone_number, winner_delivery_address = @winner_delivery_address where fwb_prize_draw_info_id = @fwb_prize_draw_info_id";
                DBServerProvider.SqlDapper.ExcuteNonQuery(sql, new { winner_name, winner_phone_number, winner_delivery_address, fwb_prize_draw_info_id });
            }catch(Exception e) {
                Console.WriteLine(e.Message);
            }
            
            return true;
        }
    }
}
